<?php
/**
 * 平台支付交易记录专属类，请勿污染
 * User: lanlc
 * Date: 17-2-28
 * Time: 上午10:36
 */

namespace app\backend\model;

use think\Model;

class JournalPlatform extends Model
{
    public function __construct() {
        parent::__construct();
    }

    private $_table      = 'z_member_journal';  //类对象对应的数据库表
    private $_id         = '';  //表自增ID
    private $_mid        = '';  //当前用户
    private $_dMoney     = '';  //交易金额
    private $_lMoney     = '';  //交易金额
    private $_orderId    = '';  //订单id
    private $_orderNum   = '';  //订单号
    private $_fromId     = '';  //对方用户
    private $_action     = '';  //增减款：0增，1减
    private $_rectime    = '';  //添加时间
    private $_operator   = '';  //操作员
    private $_type       = '';  //交易类型
    private $_memo       = '';  //交易备注
    private $_tradeNumber= '';  //交易单号
    private $_mtype      = '';  //金钱类型

    private $_beginCycle = '';  //起始周期
    private $_endCycle   = '';  //结束周期

    /**
     * 设置全部属性方法
     * @date   2017-02-28
     * @author Lanlc
     *
     * @param
     *
     * @return
     */
    public function setAllProperty($mid, $dMoney, $lMoney, $orderId, $orderNum, $fromId, $action, $rectime, $operator, $type, $memo, $tradeNumber, $mtype, $beginCycle, $endCycle)
    {
        $this->_mid          = $mid;
        $this->_dMoney       = $dMoney;
        $this->_lMoney       = $lMoney;
        $this->_orderId      = $orderId;
        $this->_orderNum     = $orderNum;
        $this->_fromId       = $fromId;
        $this->_action       = $action;
        $this->_rectime      = $rectime;
        $this->_operator     = $operator;
        $this->_type         = $type;
        $this->_memo         = $memo;
        $this->_tradeNumber  = $tradeNumber;
        $this->_mtype        = $mtype;
        $this->_beginCycle   = $beginCycle;  //起始周期
        $this->_endCycle     = $endCycle;  //结束周期
    }
    /**
     * 判断是否是对象属性
     * @date   2017-02-28
     * @author Lanlc
     *
     * @param  string  $param  待判断的对象属性
     *
     * @return
     */
    public function _isset($param)
    {
        if (property_exists($this, $param)) {
            return true;
        } else {
            return false;
        }
    }
    /**
     * 设置对象属性
     * @date   2017-02-28
     * @author Lanlc
     *
     * @param  string  $name   属性名称
     * @param  mix     $value  属性值
     *
     * @return
     */
    public function setValue($name, $value)
    {
        if ($this->_isset($name)) {
            $this->$name = $value;
            return true;
        } else {
            return false;
        }
    }

    /**
     * 获取对象属性
     * @date   2017-02-28
     * @author Lanlc
     *
     * @param  string  $name   属性名称
     *
     * @return
     */
    public function getValue($name)
    {
        if ($this->_isset($name)) {
            return $this->$name;
        } else {
            return false;
        }
    }

    /**
     * 添加会员交易记录
     * @date   2017-02-28
     * @author Lanlc
     *
     *
     * @return
     */
    public function addRecord()
    {
        $data = [
            'mid'         => $this->_mid,
            'from_id'     => $this->_fromId,
            'dmoney'      => $this->_dMoney,
            'lmoney'      => $this->_lMoney,
            'order_id'    => $this->_orderId,
            'ordernum'    => $this->_orderNum,
            'mtype'       => $this->_mtype,
            'action'      => $this->_action,
            'rectime'     => time(),
            'operator'    => $this->_operator,
            'type'        => $this->_type,
            'memo'        => $this->_memo,
            'trade_no'    => $this->_tradeNumber,
            'begin_cycle' => $this->_beginCycle,
            'end_cycle'   => $this->_endCycle,
        ];
        $addResult = $this->setTable($this->_table)->insertGetId($data);

        return $addResult ? $addResult : false;
    }

    /**
     * 获取交易记录:后期根据需求进行相应的开发，切勿乱传参数
     * @date   2017-02-28
     * @author Lanlc
     *
     * @return
     */
    public function getRecord()
    {
    }
}
